#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define maxn 10005
#define maxh 1005
const int INF = 1<<30;

int L,H,k;
int _inc[maxn],_dec[maxn];
int pup[maxn], pdown[maxn];
struct Pipe {
	int x, pup, pdown;
	bool operator< (Pipe a){
		return this->x < a.x;
	}
}pipe[maxn];
bool pass = false;
int dp1[maxh][maxn], dp2[maxh][maxn];

//Return value is max pipe num
int dfs1(int h, int x){
	if(pass) return 0;
	if(h>H) h=H;
	if(x==L){ pass=true; return 0; }
	if(h<=0 || h>=pup[x] || h<=pdown[x]) return 0; 
	if(dp1[h][x]>=0) return dp1[h][x];
	int ret0 = dfs1(h-_dec[x], x+1)+1;
	int ret1 = 0;
	for(int i=1; i<=(H-h)/_inc[x]+1; i++){
		ret1 = max(ret1, dfs1(h+_inc[x]*i, x+1)+1);
	}
	return dp1[h][x] = max(ret0, ret1);
}
//Return value is min touch num
int dfs2(int h, int x){
	if(h>H) h=H;
	if(h<=0 || h>=pup[x] || h<=pdown[x]) return INF;
	if(x==L) return 0;
	if(dp2[h][x]>=0) return dp2[h][x];
	int ret0 = dfs2(h-_dec[x], x+1);
	int ret1 = INF;
	for(int i=1; i<=(H-h)/_inc[x]+1; i++){
		ret1 = min(ret1, dfs2(h+_inc[x]*i, x+1)+i);
	}
	return dp2[h][x] = min(ret0, ret1);
}

int main(){
	memset(dp1, -1, sizeof(dp1));
	memset(dp2, -1, sizeof(dp2));
	cin>>L>>H>>k;
	for(int i=0;i<L;i++)
		cin>>_inc[i]>>_dec[i];
	for(int i=0;i<k;i++)
		cin>>pipe[i].x>>pipe[i].pdown>>pipe[i].pup;
	sort(pipe, pipe+k);
	for(int i=0;i<k;i++){
		pup[pipe[i].x] = pipe[i].pup;
		pdown[pipe[i].x] = pipe[i].pdown;
	}
	for(int x=0;x<=L;x++){
		if(pup[x]==0 && pdown[x]==0){
			pup[x] = H+1;
			pdown[x] = 0;
		}
	}
	
	int maxdis=0;
	for(int ih=1;ih<=H;ih++){
		maxdis = max(maxdis, dfs1(ih, 0));
		if(maxdis==L || pass) break;
	}
	if(maxdis==L || pass){
		cout<<"1"<<endl;
		int mintouch=INF;
		for(int ih=1;ih<=H;ih++){
			mintouch = min(mintouch, dfs2(ih, 0));
		}
		cout<<mintouch<<endl;
	}
	else{
		cout<<"0"<<endl;
		int throughpipe=0;
		for(int x=1;x<maxdis;x++){
			if(pup[x]!=H+1 || pdown[x]!=0)
				throughpipe++;
		}
		cout<<throughpipe<<endl;
	}
	return 0;
}
